/*
 * SystemPropertyControl.java
 *
 * Created on 14 September 2004, 08:59
 * Copyright (C) 2004, Velocityme Partnership
 */

package com.velocityme.client.gui.directory;

import com.velocityme.client.gui.exception.ExceptionWindow;
import com.velocityme.client.utility.StatelessRemoteClientSessionUtil;
import com.velocityme.interfaces.KeySession;
import com.velocityme.utility.DirectoryDTO;
import com.velocityme.utility.InvalidKeyException;
import com.velocityme.utility.LicenceKey;
import com.velocityme.utility.PermissionDeniedException;
import com.velocityme.valueobjects.ContactDetailTypeValue;
import java.rmi.RemoteException;
import java.util.*;
import javax.ejb.CreateException;
import javax.naming.NamingException;

/**
 *
 * @author  Robert Crida Work
 */
public class DirectoryControl extends javax.swing.JPanel {
    
    private KeySession m_key;
    private DirectoryDisplay m_directoryDisplay;
    
    /** Creates new form SystemPropertyControl */
    public DirectoryControl(KeySession p_key, Set p_setPermissions) {
        m_key = p_key;
        initComponents();
        try {
            DirectoryDTO directoryDTO = StatelessRemoteClientSessionUtil.getSession().getDirectoryDTO(m_key);
            String[] columnNames = new String[directoryDTO.getContactDetailTypeValues().length + 3];
            columnNames[0] = "Type";
            columnNames[1] = "Name";
            columnNames[2] = "Path";
            for (int i = 0; i < directoryDTO.getContactDetailTypeValues().length; i++)
                columnNames[i+3] = directoryDTO.getContactDetailTypeValues()[i].getName();
            m_directoryDisplay = new DirectoryDisplay(columnNames);
            m_directoryDisplay.setDirectoryDTO(directoryDTO);
        }
        catch(RemoteException e) {
            ExceptionWindow.showError(e);
        }
        catch(NamingException e) {
            ExceptionWindow.showError(e);
        }
        catch(CreateException e) {
            ExceptionWindow.showError(e);
        }
        catch(InvalidKeyException e) {
            ExceptionWindow.showError(e);
        }
//        catch(PermissionDeniedException e) {
//            ExceptionWindow.showError(e);
//        }
        add(m_directoryDisplay, java.awt.BorderLayout.CENTER);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {//GEN-BEGIN:initComponents

        setLayout(new java.awt.BorderLayout());

    }//GEN-END:initComponents
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
    
}
